﻿using System;
using System.Collections.Generic;
using System.Text;
using Portal.Common.Interface;
using System.Data;
using System.Collections;
using Portal.Common.Entity;

namespace Portal.Logic
{
    class DectionaryLogic : IDectionary
    {
        /// <summary>
        /// 根据登陆名查询用户权限
        /// </summary>
        /// <param name="UserCode">登陆账号</param>
        /// <returns>权限集合</returns>
        public List<DectionaryEntity> GetList(string UserCode)
        {
            Hashtable ht = new Hashtable();
            if (UserCode.ToLower() == "administrator")
            {
                return DataHelper.Instance().GetList<DectionaryEntity>("DectionaryLogic_GetAllMune", ht);
            }
            ht.Add("AdAccount", UserCode);
            return DataHelper.Instance().GetList<DectionaryEntity>("DectionaryLogic_GetParentMune", ht);
        }

        /// <summary>
        /// 根据父节点ID查找子节点
        /// </summary>
        /// <param name="parentId">父节点ID</param>
        /// <returns>子节点集合</returns>
        public List<DectionaryEntity> GetSubList(string parentId)
        {
            Hashtable ht = new Hashtable();
            ht.Add("parentId", parentId);
            List<DectionaryEntity> subLists = DataHelper.Instance().GetList<DectionaryEntity>("DectionaryLogic_GetSubMune", ht);
            return subLists;
        }

        /// <summary>
        /// 根据ID获取记录信息
        /// </summary>
        /// <param name="did"></param>
        /// <returns></returns>
        public List<DectionaryEntity> GetById(string did)
        {
            Hashtable ht = new Hashtable();
            ht.Add("id", did);
            return DataHelper.Instance().GetList<DectionaryEntity>("DectionaryLogic_GetById", ht);
        }
    }
}
